#!/usr/bin/env bash

echo '=====开始更新DIDIOK前端镜像====='

echo '=====开始关闭DIDIOK前端项目的容器====='
sh vue_down.sh

echo '===== 删除DIDIOK前端镜像====='

echo '=====删除vue_didiok_admin====='
docker rmi registry.cn-hangzhou.aliyuncs.com/didiok/vue_didiok_admin
echo '=====删除vue_didiok_web====='
docker rmi registry.cn-hangzhou.aliyuncs.com/didiok/vue_didiok_web

echo '===== 阿里云 仓库认证====='
docker login --username=2505757460@qq.com --password=didiok520 registry.cn-hangzhou.aliyuncs.com

echo '=====开始更新vue_didiok_admin====='
docker pull registry.cn-hangzhou.aliyuncs.com/didiok/vue_didiok_admin

echo '=====开始更新vue_didiok_web====='
docker pull registry.cn-hangzhou.aliyuncs.com/didiok/vue_didiok_web

echo '=====删除docker标签为none的镜像====='
if [[ -n $(docker images | grep none | awk '{print $3}') ]];then
    echo "------ 存在虚悬镜像，开始删除... ------"
    docker rmi $(docker images | grep none | awk '{print $3}')
else
    echo "------ 不存在虚悬镜像 ------"
fi

echo '=====开始运行DIDIOK前端项目的容器====='
sh vue_run.sh
